package tedu.api.exception;

import java.io.FileNotFoundException;

public class Student {
    private int age;

    public int getAge() {
        return age;
    }

    public void setAge(int age) throws IllegalAgeException {//抛给调用者
        if(age<0 || age>150){
            //throw new RuntimeException();
            throw new IllegalAgeException("年龄不合法");
        }
        this.age = age;
    }

    /*public void setAge(int age) throws FileNotFoundException {//抛给调用者
        if(age<0 || age>150){
            throw new FileNotFoundException();//抛出检查异常，必须处理
            //throw new RuntimeException();//抛出非检查异常，可以不处理
        }
        this.age = age;
    }*/
}
